//
//  LiveHeaderView.m
//  VoiceLive
//
//  Created by 凸阿滨 on 2017/10/20.
//  Copyright © 2017年 WB. All rights reserved.
//

#import "LiveHeaderView.h"
#import "UIView+Frame.h"
@interface LiveHeaderView ()
@property (strong, nonatomic) IBOutlet UIButton *closeLiveBtn;
@property (strong, nonatomic) IBOutlet UIButton *slideBtn;
@property (strong, nonatomic) IBOutlet UIButton *openLiveBtn;



@end

@implementation LiveHeaderView

+ (instancetype)creatLiveHeaderView{
    return [[[NSBundle mainBundle]loadNibNamed:@"LiveHeaderView" owner:nil options:nil]lastObject];
    
}

-(void)awakeFromNib{
    [super awakeFromNib];
    self.closeLiveBtn.adjustsImageWhenHighlighted = NO;
    self.headerImage.layer.cornerRadius = self.headerImage.yj_hight * 0.5;
    self.headerImage.layer.masksToBounds = YES;
    self.headerImage.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickHeaderImage)];
    [self.headerImage addGestureRecognizer:tap];
    
}

- (void)clickHeaderImage{
    if([self.delegate respondsToSelector:@selector(pickerHeaderImage)]){
        [self.delegate pickerHeaderImage];
    }
    
}




- (IBAction)clickBlackListBtn {
    if([self.delegate respondsToSelector:@selector(showBlackList )]){
        [self.delegate showBlackList];
    }
}

- (IBAction)closeLive {
    self.closeLiveBtn.highlighted = NO;
    
    [UIView animateWithDuration:0.4 animations:^{
         self.slideBtn.yj_x = self.closeLiveBtn.yj_x;
        [self.slideBtn setTitle:@"关闭" forState:UIControlStateNormal];
        if([self.delegate respondsToSelector:@selector(endLive)]){
            [self.delegate endLive];
        }
    }];
    
    
   
    
}
- (IBAction)openLive {
    self.openLiveBtn.highlighted = NO;
    [UIView animateWithDuration:0.4 animations:^{
        self.slideBtn.yj_x = self.openLiveBtn.yj_x - 2;
       [self.slideBtn setTitle:@"直播" forState:UIControlStateNormal];
        if([self.delegate respondsToSelector:@selector(startLive )]){
            [self.delegate startLive];
        }
    }];
   
    
}

@end
